package com.practice.car.cardataapp.config;

import com.practice.car.cardataapp.interceptor.LoginInterceptor;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * demo-springboot project
 *
 * @author FlagDied
 * @date 2020/8/3
 */
@Configuration
public class WebMvcConfigurerImpl implements WebMvcConfigurer {
	@Autowired
	private LoginInterceptor loginInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(loginInterceptor).addPathPatterns("/system/**","/scheduler/**");
	}
	@Value("${qianduan}")
	@Getter@Setter
	private String url;

	@Override
	public void addCorsMappings(CorsRegistry registry) {//配置前后端跨域
		registry.addMapping("/**")
				.allowedOrigins(url)
				.allowCredentials(true);
//				.maxAge(3600)
//				.allowedMethods()//Default:Post Get Head
	}
}
